<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue路由</title>
    <script src="../../js/vue3.js"></script>
    <script src="../../js/vue-router.global.js"></script>
    <style>
        #app {
            margin: 5rem auto;
            width: 30%;
        }

        * {
            padding: 0;
            margin: 0;
        }

        .box {
            border: 1px gray solid;
            text-align: center;
        }

        .row {
            display: flex;
            justify-content: space-around;
        }

        .row>div {
            width: 33%;
            background-color: lightgray;
            border: 1px gray solid;
            font-size: 1.2rem;
            padding: 1rem;
        }

        .content {
            height: 5rem;
            padding: 1rem;
            font-size: 1.5rem;
        }
    </style>
</head>

<body>
    <!-- 运行 -->
    <div id="app">
        <div class="box">
            <div class="row">
                <div><router-link to="/animal_1">猞猁</router-link></div>
                <div><router-link to="/animal_2">雪豹</router-link></div>
                <div><router-link to="/animal_3">路由</router-link></div>
            </div>
            <div class="content">
                <router-view></router-view>
            </div>
        </div>
    </div>
    <!-- 模版 -->
    <template id="animal_1">
        <p>芝士猞猁</p>
    </template>
    <template id="animal_2">
        <p>芝士雪豹</p>
    </template>
    <template id="animal_3">
        <p>芝士路由</p>
    </template>
    <script>
        const v_app = Vue.createApp({
            data() {
                return {

                }
            },
        });
        const animal_1 = {
            template: "#animal_1",
        }
        const animal_2 = {
            template: "#animal_2",
        }
        const animal_3 = {
            template: "#animal_3",
        }
        const routes = [{
            path: "/animal_1",
            component: animal_1
        },
        {
            path: "/animal_2",
            component: animal_2
        },
        {
            path: "/animal_3",
            component: animal_3
        }]
        const router = VueRouter.createRouter({
            history: VueRouter.createWebHashHistory(),
            routes: routes
        });
        v_app.use(router);
        v_app.mount("#app");
    </script>
</body>

</html>